package com.ruoyi.system.service.impl;

import java.util.*;
import java.util.stream.Collectors;

import cn.hutool.core.date.DateUtil;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.domain.vo.DeptUnDoVo;
import com.ruoyi.system.domain.vo.UserEducationVo;
import com.ruoyi.system.domain.vo.UserUnDoVo;
import com.ruoyi.system.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.TreeSelect;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.system.mapper.SysDeptMapper;
import com.ruoyi.system.mapper.SysRoleMapper;
import org.springframework.util.ObjectUtils;

/**
 * 党组织管理 服务实现
 *
 * @author ruoyi
 */
@Service
public class SysDeptServiceImpl implements ISysDeptService
{
    @Autowired
    private SysDeptMapper deptMapper;

    @Autowired
    private SysRoleMapper roleMapper;

    @Autowired
    private IAssesRuleSystemService assesRuleSystemService;

    @Autowired
    private IAssesRuleService assesRuleService;

    @Autowired
    private IMeetingManagementService meetingManagementService;

    @Autowired
    private IActivityManagementService activityManagementService;

    @Autowired
    private IWorkSummaryService workSummaryService;



    /**
     * 查询党组织管理数据
     *
     * @param dept 党组织信息
     * @return 党组织信息集合
     */
    @Override
    @DataScope(deptAlias = "d")
    public List<SysDept> selectDeptList(SysDept dept)
    {
        List<SysDept> sysDeptList = deptMapper.selectDeptList(dept);
        for(SysDept sysDept : sysDeptList){
            String associateItem = sysDept.getAssociateItem();
            if(StringUtils.isNotBlank(associateItem)){
                List<String> associateItemList = Arrays.asList(associateItem.split(","));
                sysDept.setAssociateItemList(associateItemList);
            }
        }
        return sysDeptList;
    }

    /**
     * 查询党组织树结构信息
     *
     * @param dept 党组织信息
     * @return 党组织树信息集合
     */
    @Override
    public List<TreeSelect> selectDeptTreeList(SysDept dept)
    {
        List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
        return buildDeptTreeSelect(depts);
    }

    /**
     * 构建前端所需要树结构
     *
     * @param depts 党组织列表
     * @return 树结构列表
     */
    @Override
    public List<SysDept> buildDeptTree(List<SysDept> depts)
    {
        List<SysDept> returnList = new ArrayList<SysDept>();
        List<Long> tempList = depts.stream().map(SysDept::getDeptId).collect(Collectors.toList());
        for (SysDept dept : depts)
        {
            // 如果是顶级节点, 遍历该父节点的所有子节点
            if (!tempList.contains(dept.getParentId()))
            {
                recursionFn(depts, dept);
                returnList.add(dept);
            }
        }
        if (returnList.isEmpty())
        {
            returnList = depts;
        }
        return returnList;
    }

    /**
     * 构建前端所需要下拉树结构
     *
     * @param depts 党组织列表
     * @return 下拉树结构列表
     */
    @Override
    public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts)
    {
        List<SysDept> deptTrees = buildDeptTree(depts);
        return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
    }

    /**
     * 根据角色ID查询党组织树信息
     *
     * @param roleId 角色ID
     * @return 选中党组织列表
     */
    @Override
    public List<Long> selectDeptListByRoleId(Long roleId)
    {
        SysRole role = roleMapper.selectRoleById(roleId);
        return deptMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly());
    }

    /**
     * 根据党组织ID查询信息
     *
     * @param deptId 党组织ID
     * @return 党组织信息
     */
    @Override
    public SysDept selectDeptById(Long deptId)
    {
        SysDept sysDept = deptMapper.selectDeptById(deptId);
        String associateItem = sysDept.getAssociateItem();
        if(StringUtils.isNotBlank(associateItem)){
            List<String> associateItemList = Arrays.asList(associateItem.split(","));
            sysDept.setAssociateItemList(associateItemList);
        }
        return sysDept;
    }

    /**
     * 根据ID查询所有子党组织（正常状态）
     *
     * @param deptId 党组织ID
     * @return 子党组织数
     */
    @Override
    public int selectNormalChildrenDeptById(Long deptId)
    {
        return deptMapper.selectNormalChildrenDeptById(deptId);
    }

    /**
     * 是否存在子节点
     *
     * @param deptId 党组织ID
     * @return 结果
     */
    @Override
    public boolean hasChildByDeptId(Long deptId)
    {
        int result = deptMapper.hasChildByDeptId(deptId);
        return result > 0;
    }

    /**
     * 查询党组织是否存在用户
     *
     * @param deptId 党组织ID
     * @return 结果 true 存在 false 不存在
     */
    @Override
    public boolean checkDeptExistUser(Long deptId)
    {
        int result = deptMapper.checkDeptExistUser(deptId);
        return result > 0;
    }

    /**
     * 校验党组织名称是否唯一
     *
     * @param dept 党组织信息
     * @return 结果
     */
    @Override
    public boolean checkDeptNameUnique(SysDept dept)
    {
        Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
        SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId());
        if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue())
        {
            return UserConstants.NOT_UNIQUE;
        }
        return UserConstants.UNIQUE;
    }

    /**
     * 校验党组织是否有数据权限
     *
     * @param deptId 党组织id
     */
    @Override
    public void checkDeptDataScope(Long deptId)
    {
        if (!SysUser.isAdmin(SecurityUtils.getUserId()))
        {
            SysDept dept = new SysDept();
            dept.setDeptId(deptId);
            List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
            if (StringUtils.isEmpty(depts))
            {
                throw new ServiceException("没有权限访问党组织数据！");
            }
        }
    }

    /**
     * 新增保存党组织信息
     *
     * @param dept 党组织信息
     * @return 结果
     */
    @Override
    public int insertDept(SysDept dept)
    {
        SysDept info = deptMapper.selectDeptById(dept.getParentId());
        // 如果父节点不为正常状态,则不允许新增子节点
        if (!UserConstants.DEPT_NORMAL.equals(info.getStatus()))
        {
            throw new ServiceException("党组织停用，不允许新增");
        }
        dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
        //添加排序
        SysDept sysDept = deptMapper.selectDeptSort(dept);
        if(!ObjectUtils.isEmpty(sysDept)){
            Integer orderNum = sysDept.getOrderNum();
            int orderNumResult = orderNum + 1;
            dept.setOrderNum(orderNumResult);
        }else{
            dept.setOrderNum(1);
        }
        //关联项目
        List<String> associateItemList = dept.getAssociateItemList();
        String associateItemListString = StringUtils.join(associateItemList, ",");
        dept.setAssociateItem(associateItemListString);
        return deptMapper.insertDept(dept);
    }

    /**
     * 修改保存党组织信息
     *
     * @param dept 党组织信息
     * @return 结果
     */
    @Override
    public int updateDept(SysDept dept)
    {
        SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
        SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
        if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept))
        {
            String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
            String oldAncestors = oldDept.getAncestors();
            dept.setAncestors(newAncestors);
            updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
        }
        //关联项目
        List<String> associateItemList = dept.getAssociateItemList();
        String associateItemListString = StringUtils.join(associateItemList, ",");
        dept.setAssociateItem(associateItemListString);
        int result = deptMapper.updateDept(dept);
        if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
                && !StringUtils.equals("0", dept.getAncestors()))
        {
            // 如果该党组织是启用状态，则启用该党组织的所有上级党组织
            updateParentDeptStatusNormal(dept);
        }
        return result;
    }

    /**
     * 修改该党组织的父级党组织状态
     *
     * @param dept 当前党组织
     */
    private void updateParentDeptStatusNormal(SysDept dept)
    {
        String ancestors = dept.getAncestors();
        Long[] deptIds = Convert.toLongArray(ancestors);
        deptMapper.updateDeptStatusNormal(deptIds);
    }

    /**
     * 修改子元素关系
     *
     * @param deptId 被修改的党组织ID
     * @param newAncestors 新的父ID集合
     * @param oldAncestors 旧的父ID集合
     */
    public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors)
    {
        List<SysDept> children = deptMapper.selectChildrenDeptById(deptId);
        for (SysDept child : children)
        {
            child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors));
        }
        if (children.size() > 0)
        {
            deptMapper.updateDeptChildren(children);
        }
    }

    /**
     * 删除党组织管理信息
     *
     * @param deptId 党组织ID
     * @return 结果
     */
    @Override
    public int deleteDeptById(Long deptId)
    {
        return deptMapper.deleteDeptById(deptId);
    }

    /**
     * 递归列表
     */
    private void recursionFn(List<SysDept> list, SysDept t)
    {
        // 得到子节点列表
        List<SysDept> childList = getChildList(list, t);
        t.setChildren(childList);
        for (SysDept tChild : childList)
        {
            if (hasChild(list, tChild))
            {
                recursionFn(list, tChild);
            }
        }
    }

    /**
     * 得到子节点列表
     */
    private List<SysDept> getChildList(List<SysDept> list, SysDept t)
    {
        List<SysDept> tlist = new ArrayList<SysDept>();
        Iterator<SysDept> it = list.iterator();
        while (it.hasNext())
        {
            SysDept n = (SysDept) it.next();
            if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue())
            {
                tlist.add(n);
            }
        }
        return tlist;
    }

    /**
     * 判断是否有子节点
     */
    private boolean hasChild(List<SysDept> list, SysDept t)
    {
        return getChildList(list, t).size() > 0;
    }


    /**
     * 查询组织任务
     */
    @Override
    public List<DeptUnDoVo> selectMyTask(DeptUnDoVo deptUnDoVo){
        List<DeptUnDoVo> reslutList = new ArrayList();
        //查询当前组织的系统考核规则
        Long deptId = deptUnDoVo.getDeptId();
        SysDept sysDept = selectDeptById(deptId);
        String deptType = sysDept.getDeptType();
        AssesRule assesRule = new AssesRule();
        assesRule.setDeptType(deptType);
        assesRule.setEffectiveTerm(deptUnDoVo.getQueryYear());
        //一个部门类型对应一个规则
        AssesRule assesRuleDept = assesRuleService.selectAssesRuleByAssesRule(assesRule);
        if(ObjectUtils.isEmpty(assesRuleDept)){
            return reslutList;
        }
        //查询对应的系统规则
        AssesRuleSystem assesRuleSystem = new AssesRuleSystem();
        assesRuleSystem.setAssesRuleId(assesRuleDept.getId());
        List<AssesRuleSystem> assesRuleSystems = assesRuleSystemService.selectAssesRuleSystemList(assesRuleSystem);
        for(AssesRuleSystem systemRule : assesRuleSystems){
            // 循环模式 0:周 1:月 2:季 3:半年 4:年
            String cyclicalPattern = systemRule.getCyclicalPattern();
            if("0".equals(cyclicalPattern)){
                //按周统计数据
                String queryYear = deptUnDoVo.getQueryYear();
                int yearWeekConut = DateUtils.getYearWeekConut(Integer.valueOf(queryYear));
                for(int i = 1;i<=yearWeekConut;i++){
                    Map<String, String> weekRangeMap = DateUtils.getWeekRangeMap(Integer.valueOf(queryYear), i);
                    String startTime = weekRangeMap.get("startTime");
                    String endTime = weekRangeMap.get("endTime");
                    DeptUnDoVo deptUnDo = new DeptUnDoVo();
                    deptUnDo.setDeptId(deptId);
                    deptUnDo.setStartTime(startTime);
                    deptUnDo.setEndTime(endTime);
                    // 0:参加会议类型 1:累计会议时长 2:参加活动类型 3:累计活动时长 4:提交总结类型
                    String ruleType = systemRule.getRuleType();
                    //会议类型、活动类型、提交总结类型
                    String firstCondition = systemRule.getFirstCondition();
                    String conditionJudge = systemRule.getConditionJudge();
                    String secondCondition = systemRule.getSecondCondition();
                    deptUnDo.setCondition(conditionJudge);
                    deptUnDo.setCycle("0");
                    if("0".equals(ruleType)){
                        deptUnDo.setTaskType("0");
                        deptUnDo.setTaskName(firstCondition);
                        Date nowDate = DateUtils.getNowDate();
                        Date startDate = DateUtil.parse(startTime, "yyyy-MM-dd HH:mm:ss");
                        Date endDate = DateUtil.parse(endTime, "yyyy-MM-dd HH:mm:ss");
                        if(startDate.compareTo(nowDate)>0){
                            //未开始
                            deptUnDo.setStatus("0");
                            deptUnDo.setFinishCount("0");
                            reslutList.add(deptUnDo);
                            continue;
                        }
                        handleDate(reslutList,deptUnDo,systemRule,startTime,endTime,deptId);
                    }
                    else if("1".equals(ruleType)){
                        deptUnDo.setTaskType("1");
                        deptUnDo.setTaskName(firstCondition);
                        Date nowDate = DateUtils.getNowDate();
                        Date startDate = DateUtil.parse(startTime, "yyyy-MM-dd HH:mm:ss");
                        Date endDate = DateUtil.parse(endTime, "yyyy-MM-dd HH:mm:ss");
                        if(startDate.compareTo(nowDate)>0){
                            //未开始
                            deptUnDo.setStatus("0");
                            deptUnDo.setFinishCount("0");
                            reslutList.add(deptUnDo);
                            continue;
                        }
                        handleDate(reslutList,deptUnDo,systemRule,startTime,endTime,deptId);
                    }
                    else if("2".equals(ruleType)){
                        deptUnDo.setTaskType("2");
                        deptUnDo.setTaskName(firstCondition);
                        Date nowDate = DateUtils.getNowDate();
                        Date startDate = DateUtil.parse(startTime, "yyyy-MM-dd HH:mm:ss");
                        Date endDate = DateUtil.parse(endTime, "yyyy-MM-dd HH:mm:ss");
                        if(startDate.compareTo(nowDate)>0){
                            //未开始
                            deptUnDo.setStatus("0");
                            deptUnDo.setFinishCount("0");
                            reslutList.add(deptUnDo);
                            continue;
                        }
                        handleDate(reslutList,deptUnDo,systemRule,startTime,endTime,deptId);
                    }
                    else if("3".equals(ruleType)){
                        deptUnDo.setTaskType("3");
                        deptUnDo.setTaskName(firstCondition);
                        Date nowDate = DateUtils.getNowDate();
                        Date startDate = DateUtil.parse(startTime, "yyyy-MM-dd HH:mm:ss");
                        Date endDate = DateUtil.parse(endTime, "yyyy-MM-dd HH:mm:ss");
                        if(startDate.compareTo(nowDate)>0){
                            //未开始
                            deptUnDo.setStatus("0");
                            deptUnDo.setFinishCount("0");
                            reslutList.add(deptUnDo);
                            continue;
                        }
                        handleDate(reslutList,deptUnDo,systemRule,startTime,endTime,deptId);
                    }
                    else if("4".equals(ruleType)){
                        deptUnDo.setTaskType("4");
                        deptUnDo.setTaskName(firstCondition);
                        Date nowDate = DateUtils.getNowDate();
                        Date startDate = DateUtil.parse(startTime, "yyyy-MM-dd HH:mm:ss");
                        Date endDate = DateUtil.parse(endTime, "yyyy-MM-dd HH:mm:ss");
                        if(startDate.compareTo(nowDate)>0){
                            //未开始
                            deptUnDo.setStatus("0");
                            deptUnDo.setFinishCount("0");
                            reslutList.add(deptUnDo);
                            continue;
                        }
                        handleDate(reslutList,deptUnDo,systemRule,startTime,endTime,deptId);
                    }
                }
            }
            else if("1".equals(cyclicalPattern)){
                //按月统计数据
                String queryYear = deptUnDoVo.getQueryYear();
                for(int i = 1;i<=12;i++){
                    String startTime = DateUtils.getFirstDayOfMonth(Integer.valueOf(queryYear), i);
                    String endTime = DateUtils.getLastDayOfMonth(Integer.valueOf(queryYear), i);
                    DeptUnDoVo deptUnDo = new DeptUnDoVo();
                    deptUnDo.setDeptId(deptId);
                    deptUnDo.setStartTime(startTime);
                    deptUnDo.setEndTime(endTime);
                    // 0:参加会议类型 1:累计会议时长 2:参加活动类型 3:累计活动时长 4:提交总结类型
                    String ruleType = systemRule.getRuleType();
                    //会议类型、活动类型、提交总结类型
                    String firstCondition = systemRule.getFirstCondition();
                    String conditionJudge = systemRule.getConditionJudge();
                    String secondCondition = systemRule.getSecondCondition();
                    deptUnDo.setCondition(conditionJudge);
                    deptUnDo.setCycle("0");
                    if("0".equals(ruleType)){
                        deptUnDo.setTaskType("0");
                        deptUnDo.setTaskName(firstCondition);
                        Date nowDate = DateUtils.getNowDate();
                        Date startDate = DateUtil.parse(startTime, "yyyy-MM-dd HH:mm:ss");
                        Date endDate = DateUtil.parse(endTime, "yyyy-MM-dd HH:mm:ss");
                        if(startDate.compareTo(nowDate)>0){
                            //未开始
                            deptUnDo.setStatus("0");
                            deptUnDo.setFinishCount("0");
                            reslutList.add(deptUnDo);
                            continue;
                        }
                        handleDate(reslutList,deptUnDo,systemRule,startTime,endTime,deptId);
                    }
                    else if("1".equals(ruleType)){
                        deptUnDo.setTaskType("1");
                        deptUnDo.setTaskName(firstCondition);
                        Date nowDate = DateUtils.getNowDate();
                        Date startDate = DateUtil.parse(startTime, "yyyy-MM-dd HH:mm:ss");
                        Date endDate = DateUtil.parse(endTime, "yyyy-MM-dd HH:mm:ss");
                        if(startDate.compareTo(nowDate)>0){
                            //未开始
                            deptUnDo.setStatus("0");
                            deptUnDo.setFinishCount("0");
                            reslutList.add(deptUnDo);
                            continue;
                        }
                        handleDate(reslutList,deptUnDo,systemRule,startTime,endTime,deptId);
                    }
                    else if("2".equals(ruleType)){
                        deptUnDo.setTaskType("2");
                        deptUnDo.setTaskName(firstCondition);
                        Date nowDate = DateUtils.getNowDate();
                        Date startDate = DateUtil.parse(startTime, "yyyy-MM-dd HH:mm:ss");
                        Date endDate = DateUtil.parse(endTime, "yyyy-MM-dd HH:mm:ss");
                        if(startDate.compareTo(nowDate)>0){
                            //未开始
                            deptUnDo.setStatus("0");
                            deptUnDo.setFinishCount("0");
                            reslutList.add(deptUnDo);
                            continue;
                        }
                        handleDate(reslutList,deptUnDo,systemRule,startTime,endTime,deptId);
                    }
                    else if("3".equals(ruleType)){
                        deptUnDo.setTaskType("3");
                        deptUnDo.setTaskName(firstCondition);
                        Date nowDate = DateUtils.getNowDate();
                        Date startDate = DateUtil.parse(startTime, "yyyy-MM-dd HH:mm:ss");
                        Date endDate = DateUtil.parse(endTime, "yyyy-MM-dd HH:mm:ss");
                        if(startDate.compareTo(nowDate)>0){
                            //未开始
                            deptUnDo.setStatus("0");
                            deptUnDo.setFinishCount("0");
                            reslutList.add(deptUnDo);
                            continue;
                        }
                        handleDate(reslutList,deptUnDo,systemRule,startTime,endTime,deptId);
                    }
                    else if("4".equals(ruleType)){
                        deptUnDo.setTaskType("4");
                        deptUnDo.setTaskName(firstCondition);
                        Date nowDate = DateUtils.getNowDate();
                        Date startDate = DateUtil.parse(startTime, "yyyy-MM-dd HH:mm:ss");
                        Date endDate = DateUtil.parse(endTime, "yyyy-MM-dd HH:mm:ss");
                        if(startDate.compareTo(nowDate)>0){
                            //未开始
                            deptUnDo.setStatus("0");
                            deptUnDo.setFinishCount("0");
                            reslutList.add(deptUnDo);
                            continue;
                        }
                        handleDate(reslutList,deptUnDo,systemRule,startTime,endTime,deptId);
                    }
                }
            }
            else if ("2".equals(cyclicalPattern)){
                //按季统计数据
                String queryYear = deptUnDoVo.getQueryYear();
                for(int i = 1; i<=4;i++){
                    String startTime = "";
                    String endTime = "";
                    if(i==1){
                        startTime = queryYear+"-01-01 00:00:00";
                        endTime = queryYear+"-03-31 23:59:59";
                    }else if(i==2){
                        startTime = queryYear+"-04-01 00:00:00";
                        endTime = queryYear+"-06-30 23:59:59";
                    }else if(i==3){
                        startTime = queryYear+"-07-01 00:00:00";
                        endTime = queryYear+"-09-30 23:59:59";
                    }else if(i==4){
                        startTime = queryYear+"-10-01 00:00:00";
                        endTime = queryYear+"-12-31 23:59:59";
                    }
                    DeptUnDoVo deptUnDo = new DeptUnDoVo();
                    deptUnDo.setDeptId(deptId);
                    deptUnDo.setStartTime(startTime);
                    deptUnDo.setEndTime(endTime);
                    // 0:参加会议类型 1:累计会议时长 2:参加活动类型 3:累计活动时长 4:提交总结类型
                    String ruleType = systemRule.getRuleType();
                    //会议类型、活动类型、提交总结类型
                    String firstCondition = systemRule.getFirstCondition();
                    String conditionJudge = systemRule.getConditionJudge();
                    String secondCondition = systemRule.getSecondCondition();
                    deptUnDo.setCondition(conditionJudge);
                    deptUnDo.setCycle("0");
                    if("0".equals(ruleType)){
                        deptUnDo.setTaskType("0");
                        deptUnDo.setTaskName(firstCondition);
                        Date nowDate = DateUtils.getNowDate();
                        Date startDate = DateUtil.parse(startTime, "yyyy-MM-dd HH:mm:ss");
                        Date endDate = DateUtil.parse(endTime, "yyyy-MM-dd HH:mm:ss");
                        if(startDate.compareTo(nowDate)>0){
                            //未开始
                            deptUnDo.setStatus("0");
                            deptUnDo.setFinishCount("0");
                            reslutList.add(deptUnDo);
                            continue;
                        }
                        handleDate(reslutList,deptUnDo,systemRule,startTime,endTime,deptId);
                    }
                    else if("1".equals(ruleType)){
                        deptUnDo.setTaskType("1");
                        deptUnDo.setTaskName(firstCondition);
                        Date nowDate = DateUtils.getNowDate();
                        Date startDate = DateUtil.parse(startTime, "yyyy-MM-dd HH:mm:ss");
                        Date endDate = DateUtil.parse(endTime, "yyyy-MM-dd HH:mm:ss");
                        if(startDate.compareTo(nowDate)>0){
                            //未开始
                            deptUnDo.setStatus("0");
                            deptUnDo.setFinishCount("0");
                            reslutList.add(deptUnDo);
                            continue;
                        }
                        handleDate(reslutList,deptUnDo,systemRule,startTime,endTime,deptId);
                    }
                    else if("2".equals(ruleType)){
                        deptUnDo.setTaskType("2");
                        deptUnDo.setTaskName(firstCondition);
                        Date nowDate = DateUtils.getNowDate();
                        Date startDate = DateUtil.parse(startTime, "yyyy-MM-dd HH:mm:ss");
                        Date endDate = DateUtil.parse(endTime, "yyyy-MM-dd HH:mm:ss");
                        if(startDate.compareTo(nowDate)>0){
                            //未开始
                            deptUnDo.setStatus("0");
                            deptUnDo.setFinishCount("0");
                            reslutList.add(deptUnDo);
                            continue;
                        }
                        handleDate(reslutList,deptUnDo,systemRule,startTime,endTime,deptId);
                    }
                    else if("3".equals(ruleType)){
                        deptUnDo.setTaskType("3");
                        deptUnDo.setTaskName(firstCondition);
                        Date nowDate = DateUtils.getNowDate();
                        Date startDate = DateUtil.parse(startTime, "yyyy-MM-dd HH:mm:ss");
                        Date endDate = DateUtil.parse(endTime, "yyyy-MM-dd HH:mm:ss");
                        if(startDate.compareTo(nowDate)>0){
                            //未开始
                            deptUnDo.setStatus("0");
                            deptUnDo.setFinishCount("0");
                            reslutList.add(deptUnDo);
                            continue;
                        }
                        handleDate(reslutList,deptUnDo,systemRule,startTime,endTime,deptId);
                    }
                    else if("4".equals(ruleType)){
                        deptUnDo.setTaskType("4");
                        deptUnDo.setTaskName(firstCondition);
                        Date nowDate = DateUtils.getNowDate();
                        Date startDate = DateUtil.parse(startTime, "yyyy-MM-dd HH:mm:ss");
                        Date endDate = DateUtil.parse(endTime, "yyyy-MM-dd HH:mm:ss");
                        if(startDate.compareTo(nowDate)>0){
                            //未开始
                            deptUnDo.setStatus("0");
                            deptUnDo.setFinishCount("0");
                            reslutList.add(deptUnDo);
                            continue;
                        }
                        handleDate(reslutList,deptUnDo,systemRule,startTime,endTime,deptId);
                    }
                }

            }
            else if ("3".equals(cyclicalPattern)){
                //按半年统计数据
                String queryYear = deptUnDoVo.getQueryYear();
                for(int i = 1; i<=2;i++){
                    String startTime = "";
                    String endTime = "";
                    if(i==1){
                        startTime = queryYear+"-01-01 00:00:00";
                        endTime = queryYear+"-06-30 23:59:59";
                    }else if(i==2){
                        startTime = queryYear+"-07-01 00:00:00";
                        endTime = queryYear+"-12-31 23:59:59";
                    }
                    DeptUnDoVo deptUnDo = new DeptUnDoVo();
                    deptUnDo.setDeptId(deptId);
                    deptUnDo.setStartTime(startTime);
                    deptUnDo.setEndTime(endTime);
                    // 0:参加会议类型 1:累计会议时长 2:参加活动类型 3:累计活动时长 4:提交总结类型
                    String ruleType = systemRule.getRuleType();
                    //会议类型、活动类型、提交总结类型
                    String firstCondition = systemRule.getFirstCondition();
                    String conditionJudge = systemRule.getConditionJudge();
                    String secondCondition = systemRule.getSecondCondition();
                    deptUnDo.setCondition(conditionJudge);
                    deptUnDo.setCycle("0");
                    if("0".equals(ruleType)){
                        deptUnDo.setTaskType("0");
                        deptUnDo.setTaskName(firstCondition);
                        Date nowDate = DateUtils.getNowDate();
                        Date startDate = DateUtil.parse(startTime, "yyyy-MM-dd HH:mm:ss");
                        Date endDate = DateUtil.parse(endTime, "yyyy-MM-dd HH:mm:ss");
                        if(startDate.compareTo(nowDate)>0){
                            //未开始
                            deptUnDo.setStatus("0");
                            deptUnDo.setFinishCount("0");
                            reslutList.add(deptUnDo);
                            continue;
                        }
                        handleDate(reslutList,deptUnDo,systemRule,startTime,endTime,deptId);
                    }
                    else if("1".equals(ruleType)){
                        deptUnDo.setTaskType("1");
                        deptUnDo.setTaskName(firstCondition);
                        Date nowDate = DateUtils.getNowDate();
                        Date startDate = DateUtil.parse(startTime, "yyyy-MM-dd HH:mm:ss");
                        Date endDate = DateUtil.parse(endTime, "yyyy-MM-dd HH:mm:ss");
                        if(startDate.compareTo(nowDate)>0){
                            //未开始
                            deptUnDo.setStatus("0");
                            deptUnDo.setFinishCount("0");
                            reslutList.add(deptUnDo);
                            continue;
                        }
                        handleDate(reslutList,deptUnDo,systemRule,startTime,endTime,deptId);
                    }
                    else if("2".equals(ruleType)){
                        deptUnDo.setTaskType("2");
                        deptUnDo.setTaskName(firstCondition);
                        Date nowDate = DateUtils.getNowDate();
                        Date startDate = DateUtil.parse(startTime, "yyyy-MM-dd HH:mm:ss");
                        Date endDate = DateUtil.parse(endTime, "yyyy-MM-dd HH:mm:ss");
                        if(startDate.compareTo(nowDate)>0){
                            //未开始
                            deptUnDo.setStatus("0");
                            deptUnDo.setFinishCount("0");
                            reslutList.add(deptUnDo);
                            continue;
                        }
                        handleDate(reslutList,deptUnDo,systemRule,startTime,endTime,deptId);
                    }
                    else if("3".equals(ruleType)){
                        deptUnDo.setTaskType("3");
                        deptUnDo.setTaskName(firstCondition);
                        Date nowDate = DateUtils.getNowDate();
                        Date startDate = DateUtil.parse(startTime, "yyyy-MM-dd HH:mm:ss");
                        Date endDate = DateUtil.parse(endTime, "yyyy-MM-dd HH:mm:ss");
                        if(startDate.compareTo(nowDate)>0){
                            //未开始
                            deptUnDo.setStatus("0");
                            deptUnDo.setFinishCount("0");
                            reslutList.add(deptUnDo);
                            continue;
                        }
                        handleDate(reslutList,deptUnDo,systemRule,startTime,endTime,deptId);
                    }
                    else if("4".equals(ruleType)){
                        deptUnDo.setTaskType("4");
                        deptUnDo.setTaskName(firstCondition);
                        Date nowDate = DateUtils.getNowDate();
                        Date startDate = DateUtil.parse(startTime, "yyyy-MM-dd HH:mm:ss");
                        Date endDate = DateUtil.parse(endTime, "yyyy-MM-dd HH:mm:ss");
                        if(startDate.compareTo(nowDate)>0){
                            //未开始
                            deptUnDo.setStatus("0");
                            deptUnDo.setFinishCount("0");
                            reslutList.add(deptUnDo);
                            continue;
                        }
                        handleDate(reslutList,deptUnDo,systemRule,startTime,endTime,deptId);
                    }
                }

            }
            else if("4".equals(cyclicalPattern)){
                //按年统计
                String queryYear = deptUnDoVo.getQueryYear();
                String startTime = queryYear+"-01-01 00:00:00";
                String endTime = queryYear+"-12-31 23:59:59";
                DeptUnDoVo deptUnDo = new DeptUnDoVo();
                deptUnDo.setDeptId(deptId);
                deptUnDo.setStartTime(startTime);
                deptUnDo.setEndTime(endTime);
                // 0:参加会议类型 1:累计会议时长 2:参加活动类型 3:累计活动时长 4:提交总结类型
                String ruleType = systemRule.getRuleType();
                //会议类型、活动类型、提交总结类型
                String firstCondition = systemRule.getFirstCondition();
                String conditionJudge = systemRule.getConditionJudge();
                String secondCondition = systemRule.getSecondCondition();
                deptUnDo.setCondition(conditionJudge);
                deptUnDo.setCycle("0");
                if("0".equals(ruleType)){
                    deptUnDo.setTaskType("0");
                    deptUnDo.setTaskName(firstCondition);
                    Date nowDate = DateUtils.getNowDate();
                    Date startDate = DateUtil.parse(startTime, "yyyy-MM-dd HH:mm:ss");
                    Date endDate = DateUtil.parse(endTime, "yyyy-MM-dd HH:mm:ss");
                    if(startDate.compareTo(nowDate)>0){
                        //未开始
                        deptUnDo.setStatus("0");
                        deptUnDo.setFinishCount("0");
                        reslutList.add(deptUnDo);
                        return reslutList;
                    }
                    handleDate(reslutList,deptUnDo,systemRule,startTime,endTime,deptId);
                }
                else if("1".equals(ruleType)){
                    deptUnDo.setTaskType("1");
                    deptUnDo.setTaskName(firstCondition);
                    Date nowDate = DateUtils.getNowDate();
                    Date startDate = DateUtil.parse(startTime, "yyyy-MM-dd HH:mm:ss");
                    Date endDate = DateUtil.parse(endTime, "yyyy-MM-dd HH:mm:ss");
                    if(startDate.compareTo(nowDate)>0){
                        //未开始
                        deptUnDo.setStatus("0");
                        deptUnDo.setFinishCount("0");
                        reslutList.add(deptUnDo);
                        return reslutList;
                    }
                    handleDate(reslutList,deptUnDo,systemRule,startTime,endTime,deptId);
                }
                else if("2".equals(ruleType)){
                    deptUnDo.setTaskType("2");
                    deptUnDo.setTaskName(firstCondition);
                    Date nowDate = DateUtils.getNowDate();
                    Date startDate = DateUtil.parse(startTime, "yyyy-MM-dd HH:mm:ss");
                    Date endDate = DateUtil.parse(endTime, "yyyy-MM-dd HH:mm:ss");
                    if(startDate.compareTo(nowDate)>0){
                        //未开始
                        deptUnDo.setStatus("0");
                        deptUnDo.setFinishCount("0");
                        reslutList.add(deptUnDo);
                        return reslutList;
                    }
                    handleDate(reslutList,deptUnDo,systemRule,startTime,endTime,deptId);
                }
                else if("3".equals(ruleType)){
                    deptUnDo.setTaskType("3");
                    deptUnDo.setTaskName(firstCondition);
                    Date nowDate = DateUtils.getNowDate();
                    Date startDate = DateUtil.parse(startTime, "yyyy-MM-dd HH:mm:ss");
                    Date endDate = DateUtil.parse(endTime, "yyyy-MM-dd HH:mm:ss");
                    if(startDate.compareTo(nowDate)>0){
                        //未开始
                        deptUnDo.setStatus("0");
                        deptUnDo.setFinishCount("0");
                        reslutList.add(deptUnDo);
                        return reslutList;
                    }
                    handleDate(reslutList,deptUnDo,systemRule,startTime,endTime,deptId);
                }
                else if("4".equals(ruleType)){
                    deptUnDo.setTaskType("4");
                    deptUnDo.setTaskName(firstCondition);
                    Date nowDate = DateUtils.getNowDate();
                    Date startDate = DateUtil.parse(startTime, "yyyy-MM-dd HH:mm:ss");
                    Date endDate = DateUtil.parse(endTime, "yyyy-MM-dd HH:mm:ss");
                    if(startDate.compareTo(nowDate)>0){
                        //未开始
                        deptUnDo.setStatus("0");
                        deptUnDo.setFinishCount("0");
                        reslutList.add(deptUnDo);
                        return reslutList;
                    }
                    handleDate(reslutList,deptUnDo,systemRule,startTime,endTime,deptId);
                }
            }
        }
        String taskType = deptUnDoVo.getTaskType();
        if(StringUtils.isNotBlank(taskType)){
            reslutList = reslutList.stream().filter(o -> o.getTaskType().equals(taskType)).collect(Collectors.toList());
        }
        return reslutList;
    }

    public void handleDate(List<DeptUnDoVo> reslutList,DeptUnDoVo deptUnDo,AssesRuleSystem systemRule,String startTime,String endTime,Long deptId){
         String ruleType = systemRule.getRuleType();
         String firstCondition = systemRule.getFirstCondition();
         String secondCondition = systemRule.getSecondCondition();
         String conditionJudge = systemRule.getConditionJudge();
         Date nowDate = DateUtils.getNowDate();
         Date startDate = DateUtil.parse(startTime, "yyyy-MM-dd HH:mm:ss");
         Date endDate = DateUtil.parse(endTime, "yyyy-MM-dd HH:mm:ss");
        if("0".equals(ruleType)){
            //查询部门召开会议次数
            MeetingManagement meetingManagement = new MeetingManagement();
            meetingManagement.setMeetingType(firstCondition);
            meetingManagement.setDeptId(deptId);
            meetingManagement.setMeetingStartTime(startTime);
            meetingManagement.setMeetingEndTime(endTime);
            List<MeetingManagement> meetingManagements = meetingManagementService.selectMeetingManagementList(meetingManagement);
            int count = meetingManagements.size();
            deptUnDo.setFinishCount(String.valueOf(count));
            if("0".equals(conditionJudge)){
                //大于
                if(count>Integer.valueOf(secondCondition)){
                    //已完成
                    deptUnDo.setStatus("2");
                }else{
                    //当前时间在开始时间和结束时间中间，进行中
                    if(startDate.compareTo(nowDate)<0&&endDate.compareTo(nowDate)>0){
                        deptUnDo.setStatus("1");
                    }else{
                        //结束时间之后，超期未完成
                        deptUnDo.setStatus("3");
                    }
                }
            }
            else if("1".equals(conditionJudge)){
                //小于
                if(count<Integer.valueOf(secondCondition)){
                    //已完成
                    deptUnDo.setStatus("2");
                }else{
                    //当前时间在开始时间和结束时间中间，进行中
                    if(startDate.compareTo(nowDate)<0&&endDate.compareTo(nowDate)>0){
                        deptUnDo.setStatus("1");
                    }else{
                        //结束时间之后，超期未完成
                        deptUnDo.setStatus("3");
                    }
                }
            }
            reslutList.add(deptUnDo);
        }
        else if("1".equals(ruleType)){
            //查询部门召开会议时长
            MeetingManagement meetingManagement = new MeetingManagement();
            meetingManagement.setMeetingType(firstCondition);
            meetingManagement.setDeptId(deptId);
            meetingManagement.setMeetingStartTime(startTime);
            meetingManagement.setMeetingEndTime(endTime);
            List<MeetingManagement> meetingManagements = meetingManagementService.selectMeetingManagementList(meetingManagement);
            Long differenceTime = 0L;
            for(MeetingManagement meeting : meetingManagements){
                String meetingStartTime = meeting.getMeetingStartTime();
                String meetingEndTime = meeting.getMeetingEndTime();
                Date meetingStart = DateUtil.parse(meetingStartTime);
                Date meetingEnd = DateUtil.parse(meetingEndTime);
                long difference = meetingEnd.getTime() - meetingStart.getTime();
                differenceTime = differenceTime+difference;
            }
            long hour = differenceTime / (60 * 60 * 1000);
            deptUnDo.setFinishCount(String.valueOf(hour));
            if("0".equals(conditionJudge)){
                //大于
                if(hour>Integer.valueOf(secondCondition)){
                    //已完成
                    deptUnDo.setStatus("2");
                }else{
                    //当前时间在开始时间和结束时间中间，进行中
                    if(startDate.compareTo(nowDate)<0&&endDate.compareTo(nowDate)>0){
                        deptUnDo.setStatus("1");
                    }else{
                        //结束时间之后，超期未完成
                        deptUnDo.setStatus("3");
                    }
                }
            }else if("1".equals(conditionJudge)){
                //小于
                if(hour<Integer.valueOf(secondCondition)){
                    //已完成
                    deptUnDo.setStatus("2");
                }else{
                    //当前时间在开始时间和结束时间中间，进行中
                    if(startDate.compareTo(nowDate)<0&&endDate.compareTo(nowDate)>0){
                        deptUnDo.setStatus("1");
                    }else{
                        //结束时间之后，超期未完成
                        deptUnDo.setStatus("3");
                    }
                }
            }
            reslutList.add(deptUnDo);

        }
        else if("2".equals(ruleType)){
            //查询部门召开活动次数
            ActivityManagement activityManagement = new ActivityManagement();
            activityManagement.setActivityType(firstCondition);
            activityManagement.setDeptId(deptId);
            activityManagement.setActivityStartTime(startTime);
            activityManagement.setActivityEndTime(endTime);
            List<ActivityManagement> activityManagements = activityManagementService.selectActivityManagementList(activityManagement);
            int count = activityManagements.size();
            deptUnDo.setFinishCount(String.valueOf(count));
            if("0".equals(conditionJudge)){
                //大于
                if(count>Integer.valueOf(secondCondition)){
                    //已完成
                    deptUnDo.setStatus("2");
                }else{
                    //当前时间在开始时间和结束时间中间，进行中
                    if(startDate.compareTo(nowDate)<0&&endDate.compareTo(nowDate)>0){
                        deptUnDo.setStatus("1");
                    }else{
                        //结束时间之后，超期未完成
                        deptUnDo.setStatus("3");
                    }
                }
            }else if("1".equals(conditionJudge)){
                //小于
                if(count<Integer.valueOf(secondCondition)){
                    //已完成
                    deptUnDo.setStatus("2");
                }else{
                    //当前时间在开始时间和结束时间中间，进行中
                    if(startDate.compareTo(nowDate)<0&&endDate.compareTo(nowDate)>0){
                        deptUnDo.setStatus("1");
                    }else{
                        //结束时间之后，超期未完成
                        deptUnDo.setStatus("3");
                    }
                }
            }
            reslutList.add(deptUnDo);
        }
        else if("3".equals(ruleType)){
            //查询部门召开活动时间
            ActivityManagement activityManagement = new ActivityManagement();
            activityManagement.setActivityType(firstCondition);
            activityManagement.setDeptId(deptId);
            activityManagement.setActivityStartTime(startTime);
            activityManagement.setActivityEndTime(endTime);
            List<ActivityManagement> activityManagements = activityManagementService.selectActivityManagementList(activityManagement);

            Long differenceTime = 0L;
            for(ActivityManagement astivity : activityManagements){
                String axtivityStartTime = astivity.getActivityStartTime();
                String axtivityEndTime = astivity.getActivityEndTime();
                Date axtivityStart = DateUtil.parse(axtivityStartTime);
                Date axtivityEnd = DateUtil.parse(axtivityEndTime);
                long difference = axtivityEnd.getTime() - axtivityStart.getTime();
                differenceTime = differenceTime+difference;
            }
            long hour = differenceTime / (60 * 60 * 1000);
            deptUnDo.setFinishCount(String.valueOf(hour));
            if("0".equals(conditionJudge)){
                //大于
                if(hour>Integer.valueOf(secondCondition)){
                    //已完成
                    deptUnDo.setStatus("2");
                }else{
                    //当前时间在开始时间和结束时间中间，进行中
                    if(startDate.compareTo(nowDate)<0&&endDate.compareTo(nowDate)>0){
                        deptUnDo.setStatus("1");
                    }else{
                        //结束时间之后，超期未完成
                        deptUnDo.setStatus("3");
                    }
                }
            }else if("1".equals(conditionJudge)){
                //小于
                if(hour<Integer.valueOf(secondCondition)){
                    //已完成
                    deptUnDo.setStatus("2");
                }else{
                    //当前时间在开始时间和结束时间中间，进行中
                    if(startDate.compareTo(nowDate)<0&&endDate.compareTo(nowDate)>0){
                        deptUnDo.setStatus("1");
                    }else{
                        //结束时间之后，超期未完成
                        deptUnDo.setStatus("3");
                    }
                }
            }
            reslutList.add(deptUnDo);
        }
        else if("4".equals(ruleType)){
            //查询人员时间范围内工作总结次数
            WorkSummary workSummary = new WorkSummary();
            workSummary.setDeptId(deptId);
            workSummary.setSummaryType(firstCondition);
            workSummary.setStartTime(startTime);
            workSummary.setEndTime(endTime);
            //根据工作总结类型查询
            List<WorkSummary> workSummaries = workSummaryService.selectWorkSummaryList(workSummary);
            int count = workSummaries.size();
            deptUnDo.setFinishCount(String.valueOf(count));
            if("0".equals(conditionJudge)){
                //大于
                if(count>Integer.valueOf(secondCondition)){
                    //已完成
                    deptUnDo.setStatus("2");
                }else{
                    //当前时间在开始时间和结束时间中间，进行中
                    if(startDate.compareTo(nowDate)<0&&endDate.compareTo(nowDate)>0){
                        deptUnDo.setStatus("1");
                    }else{
                        //结束时间之后，超期未完成
                        deptUnDo.setStatus("3");
                    }
                }
            }else if("1".equals(conditionJudge)){
                //小于
                if(count<Integer.valueOf(secondCondition)){
                    //已完成
                    deptUnDo.setStatus("2");
                }else{
                    //当前时间在开始时间和结束时间中间，进行中
                    if(startDate.compareTo(nowDate)<0&&endDate.compareTo(nowDate)>0){
                        deptUnDo.setStatus("1");
                    }else{
                        //结束时间之后，超期未完成
                        deptUnDo.setStatus("3");
                    }
                }
            }
            reslutList.add(deptUnDo);
        }
    }

    /**
     * 任务分布
     */
    @Override
    public List<UserEducationVo>  taskStructure(String queryYear){
        List<UserEducationVo> userEducationVoList = new ArrayList();
        Integer count0 = 0;
        Integer count1 = 0;
        Integer count2 = 0;
        Integer count3 = 0;
        Integer count4 = 0;
        SysDept sysDept = new SysDept();
        List<SysDept> sysDepts = selectDeptList(sysDept);
        for(SysDept dept : sysDepts){
            //查询当前组织的系统考核规则
            Long deptId = dept.getDeptId();
            String deptType = dept.getDeptType();
            AssesRule assesRule = new AssesRule();
            assesRule.setDeptType(deptType);
            assesRule.setEffectiveTerm(queryYear);
            //一个部门类型对应一个规则
            AssesRule assesRuleDept = assesRuleService.selectAssesRuleByAssesRule(assesRule);
            if(ObjectUtils.isEmpty(assesRuleDept)){
                continue;
            }
            //查询对应的系统规则
            AssesRuleSystem assesRuleSystem = new AssesRuleSystem();
            assesRuleSystem.setAssesRuleId(assesRuleDept.getId());
            List<AssesRuleSystem> assesRuleSystems = assesRuleSystemService.selectAssesRuleSystemList(assesRuleSystem);
            for(AssesRuleSystem systemRule : assesRuleSystems){
                // 循环模式 0:周 1:月 2:季 3:半年 4:年
                String cyclicalPattern = systemRule.getCyclicalPattern();
                if("0".equals(cyclicalPattern)){
                    //按周统计数据
                    int yearWeekConut = DateUtils.getYearWeekConut(Integer.valueOf(queryYear));
                    for(int i = 1;i<=yearWeekConut;i++){
                        // 0:参加会议类型 1:累计会议时长 2:参加活动类型 3:累计活动时长 4:提交总结类型
                        String ruleType = systemRule.getRuleType();
                        if("0".equals(ruleType)){
                            count0++;
                        } else if("1".equals(ruleType)){
                            count1++;
                        } else if("2".equals(ruleType)){
                            count2++;
                        } else if("3".equals(ruleType)){
                            count3++;
                        } else if("4".equals(ruleType)){
                            count4++;
                        }
                    }
                }
                else if("1".equals(cyclicalPattern)){
                    for(int i = 1;i<=12;i++){
                        // 0:参加会议类型 1:累计会议时长 2:参加活动类型 3:累计活动时长 4:提交总结类型
                        String ruleType = systemRule.getRuleType();
                        if("0".equals(ruleType)){
                            count0++;
                        } else if("1".equals(ruleType)){
                            count1++;
                        } else if("2".equals(ruleType)){
                            count2++;
                        } else if("3".equals(ruleType)){
                            count3++;
                        } else if("4".equals(ruleType)){
                            count4++;
                        }
                    }
                }
                else if ("2".equals(cyclicalPattern)){
                    for(int i = 1; i<=4;i++){
                        // 0:参加会议类型 1:累计会议时长 2:参加活动类型 3:累计活动时长 4:提交总结类型
                        String ruleType = systemRule.getRuleType();
                        if("0".equals(ruleType)){
                            count0++;
                        } else if("1".equals(ruleType)){
                            count1++;
                        } else if("2".equals(ruleType)){
                            count2++;
                        } else if("3".equals(ruleType)){
                            count3++;
                        } else if("4".equals(ruleType)){
                            count4++;
                        }
                    }
                }
                else if("3".equals(cyclicalPattern)){
                    //按半年统计数据
                    for(int i = 1; i<=2;i++){
                        // 0:参加会议类型 1:累计会议时长 2:参加活动类型 3:累计活动时长 4:提交总结类型
                        String ruleType = systemRule.getRuleType();
                        if("0".equals(ruleType)){
                            count0++;
                        } else if("1".equals(ruleType)){
                            count1++;
                        } else if("2".equals(ruleType)){
                            count2++;
                        } else if("3".equals(ruleType)){
                            count3++;
                        } else if("4".equals(ruleType)){
                            count4++;
                        }
                    }
                }
                else if("4".equals(cyclicalPattern)){
                    //按年统计数据
                    // 0:参加会议类型 1:累计会议时长 2:参加活动类型 3:累计活动时长 4:提交总结类型
                    String ruleType = systemRule.getRuleType();
                    if("0".equals(ruleType)){
                        count0++;
                    } else if("1".equals(ruleType)){
                        count1++;
                    } else if("2".equals(ruleType)){
                        count2++;
                    } else if("3".equals(ruleType)){
                        count3++;
                    } else if("4".equals(ruleType)){
                        count4++;
                    }
                }

            }
        }
        UserEducationVo userEducationVo0 = new UserEducationVo();
        userEducationVo0.setName("参加会议类型");
        userEducationVo0.setValue(count0);
        UserEducationVo userEducationVo1 = new UserEducationVo();
        userEducationVo1.setName("累计会议时长");
        userEducationVo1.setValue(count1);
        UserEducationVo userEducationVo2 = new UserEducationVo();
        userEducationVo2.setName("参加活动类型");
        userEducationVo2.setValue(count2);
        UserEducationVo userEducationVo3 = new UserEducationVo();
        userEducationVo3.setName("累计活动时长");
        userEducationVo3.setValue(count3);
        UserEducationVo userEducationVo4 = new UserEducationVo();
        userEducationVo4.setName("提交总结类型");
        userEducationVo4.setValue(count4);
        userEducationVoList.add(userEducationVo0);
        userEducationVoList.add(userEducationVo1);
        userEducationVoList.add(userEducationVo2);
        userEducationVoList.add(userEducationVo3);
        userEducationVoList.add(userEducationVo4);
        return userEducationVoList;
    }
}
